#!/usr/bin/python
import sys
sys.path.append("../classes")
from faultsanalyzer import *

print "GENERAL TEST"

conf = {"splitter" : "^^^" , "faults_min":3}
data = {
"a^^^b^^^c" : {"f1":3,"f2":1},
"a^^^bb^^^c" : {"f1":2,"f3":4},
"aa^^^bb^^^cc" : {"f2":2},
"a^^^b^^^cc" : {"f1":12,"f4":1},
}
f = FaultsAnalyzer( conf,data )
f.do_process()

print f.data
for k in f.alertdata : print "%s\n%s\n\n" % (k,f.alertdata[k])

print "assert on num 1 key a['f1'] == 17"
assert(f.alertdata[1]['a']['f1'] == 17  )
print "OK"

print "assert on num 2 key ['a^^^b']['f1'] == 15"
assert(f.alertdata[2]['a^^^b']['f1'] == 15)
print "OK"

print "assert no keys bellow faults_min"
for num in f.alertdata :
	for k in f.alertdata[num]:
		for e in f.alertdata[num][k] :
			assert( f.alertdata[num][k][e] >= conf['faults_min']   )
print "OK"
